//alert("sina.js");
function getjs(str){
	document.write("<script language='javascript' src='http://hq.sinajs.cn/list="+str+"'></script>");
}
function SZ(n)
{
getjs(n);
alert("Welcome!");
var hq_str=eval("hq_str_"+n);
var elements=hq_str.split(",");

var stockname=elements[0];
var data1=(elements[3]*1).toFixed(2);
var data2=(elements[3]-elements[2]).toFixed(2);
var data3=(elements[3]-elements[2])*100/(elements[2]*1);
var colors=["red","green"];

return processDataArray(stockname,data1,data2,data3,colors);
}

function OTHER(n)
{
getjs(n);
alert("Welcome!");
var hq_str=eval("hq_str_"+n);
var elements=hq_str.split(",");

var stockname=elements[0];
var data1=elements[1];
var data2=elements[2];
var data3=elements[3];
var colors=["green","red"];

return processDataArray(stockname,data1,data2,data3,colors);
}

function processDataArray(stockname,data1,data2,data3,colors)
{
    data3=isNaN(data3*1)?"--":(data3*1).toFixed(2);
    if(data2*1>0)
    {data2="+"+data2;
        data3='<span class="'+colors[0]+'">+'+data3+"%</span>";
     }
    if(data2*1<0)
    {
         data3='<span class="'+colors[1]+'">'+data3+"%</span>";
     }
     return[stockname,data1,data2,data3];
}

function displayData(result)
{
    document.write("<ul><li>"+result[0]+"</li>"+"<li>收盘"+result[1]+"</li><li>涨幅"+result[2]+"</li><li>"+result[3]+"</li></ul>")
}
//displayData(SZ("sh000001")); //上证指数
//displayData(SZ("sz399001"));  //深证成指
//displayData(OTHER("int_dji"));//道琼斯
//displayData(OTHER("int_nasdaq")); //纳斯达克
//displayData(OTHER("int_hangseng")); //恒生
//displayData(OTHER("int_nikkei")); 日经指数
//displayData(OTHER("b_TWSE")); 台湾加权
//displayData(OTHER("b_FSSTI")); //新加坡
